//Mon Aug  1 14:36:00 IST 2011
#include <stdio.h>
#include <stdlib.h>

typedef struct stacktag {
	int data;

	struct stacktag *older;
}stack;

stack * push (stack *s, int data)
{
	stack *node;

	node = malloc(sizeof(stack));

	node->data = data;
	node->older = s;

	printf ("Pushed %d\n", data);

	return node;
}

stack * pop (stack *s, int *value)
{
	stack *temp = NULL;

	if (s) {
		*value = s->data;
		printf ("Popped the value %d\n", *value);
		temp = s->older;
		free (s);
	}
		
	return temp;
}

int main()
{
	stack *s;
	int val;

	s = push (NULL, 1);
	s = push (s, 2);
	s = push (s, 3);
	s = pop (s, &val);
	s = push (s, 4);
	s = push (s, 5);


	s = pop (s, &val);
	s = pop (s, &val);
	s = pop (s, &val);
	s = pop (s, &val);
	s = pop (s, &val);
	s = pop (s, &val);

	return 0;
}
//Mon Aug  1 14:45:46 IST 2011
